{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}}
<form class="form-horizontal" id="credentials_config">
  <div class="panel panel-default">
    {{#if (eq mode 'edit')}}
      <div class="panel-heading" id="credential-head">
        <span>Edit - {{credential.name}}</span><span class="cred-type">({{credential.type}})</span>
      </div>
    {{else if (eq mode 'create')}}
      <div class="panel-heading" id="credential-head">Create New</div>
    {{/if}}
    <div class="panel-body">
      <div class="form-group">
        <label class="control-label col-xs-2">Name<span class="requiredField">&nbsp;*</span></label>
        <div class=" col-xs-4">
          {{input class="form-control" type="text" value=credential.name}}
          {{field-error model=this field='credential.name' showErrorMessage=showErrorMessage}}
        </div>
      </div>
      <div class="form-group">
        <label class="control-label col-xs-2">Type<span class="requiredField">&nbsp;*</span></label>
        <div class="col-xs-4">
          <select class="form-control" name="credential-type" title="Credential Type" onchange={{action (mut credential.type) value="target.value"}}>
            {{#each credentialType as |type|}}
              <option value={{type.value}} selected={{eq type.value credential.type}}>{{type.displayName}}</option>
            {{/each}}
          </select>
          {{field-error model=this field='credential.type' showErrorMessage=showErrorMessage}}
        </div>
      </div>
      {{#if credential.type}}
        <div class="panel panel-default">
          <div class="panel-heading">Properties</div>
          <div class="panel-body handlerPanel">
            {{#each staticProps as |property|}}
              {{#named-properties property=property unregisterRequired=true required=true unregister="unregister" register="register" labelWidthClass="col-xs-4" inputWidthClass="col-xs-8"}}{{/named-properties}}
            {{/each}}
          </div>
        </div>
      {{/if}}
      <div class=" panel panel-default">
        <div class="panel-heading">Custom Properties</div>
        <div class="panel-body handlerPanel">
          <div class="form-group">
            {{#if (eq mode 'edit')}}
              <label class="control-label col-xs-4">Name</label>
              <label class="control-label col-xs-4">Value</label>
            {{/if}}
          </div>
          {{#name-value-config configuration=credential register="register"}}{{/name-value-config}}
        </div>
      </div>
      <div class="col-xs-24 pull-right">
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
        {{#if (eq mode 'create')}}
          <input class="btn btn-primary" type="button" {{action "add"}} value="Add">
        {{else}}
          <input class="btn btn-primary" type="button" {{action "add"}} value="Update">
        {{/if}}
      </div>
    </div>
  </div>
</form>
